08cb9b2f2fbffba905d87ea1e823d02565226574,Minecraft/src/main/java/com/microsoft/Malmo/Utils/BlockDrawingHelper.java,BlockDrawingHelper,DrawPrimitive,#DrawLine#World#,169
Before Change
private static void DrawPrimitive( DrawLine l, World w ) throws Exception
{
// Set up the blocktype for the main blocks of the line:
IBlockState blockType = MinecraftTypeHelper.ParseBlockType( l.getType().value() );
if( blockType == null )
throw new Exception("Unrecognised block type: " + l.getType().value());
blockType = applyModifications(blockType, l.getColour(), l.getFace(), l.getVariant());
// Set up the blocktype for the steps of the line, if one has been specified:
BlockType btNormal = l.getType();
BlockType btStep = l.getType();
IBlockState stepType = blockType;
if (l.getSteptype() != null)
{
stepType = MinecraftTypeHelper.ParseBlockType( l.getSteptype().value() );
if( stepType == null )
throw new Exception("Unrecognised block type: " + l.getSteptype().value());
stepType = applyModifications(stepType, l.getColour(), l.getFace(), l.getVariant());
btStep = l.getSteptype();
}
float dx = (l.getX2() - l.getX1());
float dy = (l.getY2() - l.getY1());
float dz = (l.getZ2() - l.getZ1());
float steps = (int)Math.max(Math.max(Math.abs(dx), Math.abs(dy)), Math.abs(dz));
if (steps < 1)
steps = 1;
dx /= steps;
dy /= steps;
dz /= steps;
int prevY = l.getY1();
int prevZ = l.getZ1();
int prevX = l.getX1();
for (int i = 0; i <= steps; i++)
{
int x = Math.round(l.getX1() + (float)i * dx);
int y = Math.round(l.getY1() + (float)i * dy);
int z = Math.round(l.getZ1() + (float)i * dz);
BlockPos pos = new BlockPos(x, y, z);
clearEntities(w, x-0.5,y-0.5,z-0.5,x+0.5,y+0.5,z+0.5);
w.setBlockState(pos, y == prevY ? blockType : stepType);
applyTileEntityProps(pos, w, y == prevY ? btNormal : btStep, l.getColour(), l.getFace(), l.getVariant());
// Ensure 4-connected:
if (x != prevX && z != prevZ)
{
pos = new BlockPos(x, y, prevZ);
clearEntities(w, x-0.5,y-0.5,prevZ-0.5,x+0.5,y+0.5,prevZ+0.5);
w.setBlockState(pos, y == prevY ? blockType : stepType);
applyTileEntityProps(pos, w, y == prevY ? btNormal : btStep, l.getColour(), l.getFace(), l.getVariant());
}
prevY = y;
prevX = x;
After Change
XMLBlockState stepType = blockType;
if (l.getSteptype() != null)
{
stepType = new XMLBlockState(l.getSteptype(), l.getColour(), l.getFace(), l.getVariant());
if (!stepType.isValid())
throw new Exception("Unrecognised block type: " + l.getSteptype().value());
}